﻿(function($){
	$.fn.ckhtmleditor = function(options) {//alert(style);
	        options=$.extend({	
						style:"Default",
						width:null,
						height:null,
						urls:""
						}, options); 
	        var _this=$(this);
	        var instance = CKEDITOR.instances[_this.attr("id")];
            if(!instance)
            {
                var w=options.width;
                var h=options.height;
//                var css=["/Resources/default/css/editor.css"];
//                if((w!=null&&w!=0)||(h!=null&&h!=0)){
//                    css=["/Resources/default/css/editor.css","/AjaxServer.aspx?cmd=getwh&"+((w!=null&&w!=0)?("width="+w+"&"):"")+((h!=null&&h!=0)?("height="+h+"&"):"")];
//                }
                var arg={
                    //contentsCss:css,
                    toolbar:options.style,
                    height:(h==null||h==0)?300:(h*1+100),
                    filebrowserBrowseUrl:"/Manage/XFinder.aspx",
                    filebrowserUploadUrl: "/Manage/XFinder.aspx?swfupload=1",
                    filebrowserImageBrowseUrl: "/Manage/XFinder.aspx?fileLimit=1",
                    filebrowserImageUploadUrl: "/Manage/XFinder.aspx?swfupload=1",
                    filebrowserMultipleImageBrowseUrl: "/Manage/XFinder.aspx",
                    filebrowserFlashBrowseUrl: "/Manage/XFinder.aspx?cp=523P6YUZ0D876DF4033211D47&filetypes=flv,swf,dat",
                    filebrowserFlashUploadUrl: "/Manage/XFinder.aspx?swfupload=1",
                    
                    filebrowserWindowWidth:600,
                    filebrowserWindowHeight:530
                }
                if(options.style=="Mini"){
                    arg={
                        //contentsCss:css,
                    filebrowserWindowWidth:600,
                    filebrowserWindowHeight:530,
                    filebrowserBrowseUrl:"/Manage/XFinder.aspx",
                    filebrowserUploadUrl:"/Manage/XFinder.aspx?swfupload=1",
                    filebrowserImageBrowseUrl:"/Manage/XFinder.aspx",
                    filebrowserImageUploadUrl:"/Manage/XFinder.aspx?swfupload=1",
                    filebrowserMultipleImageBrowseUrl:"/Manage/XFinder.aspx",
                    filebrowserFlashBrowseUrl: "/Manage/XFinder.aspx?cp=523P6YUZ0D876DF4033211D47&filetypes=flv,swf,dat",
                    filebrowserFlashUploadUrl:"/Manage/XFinder.aspx?swfupload=1",
                        toolbar:options.style,
                        height:(h==null||h==0)?300:(h*1+100)
                    }
                }
                var editor = CKEDITOR.replace(_this.attr("id"),arg);
            }
	}	
})(jQuery);

